<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="../../../attr.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="${ctx}/js/jquery.js"></script>
<script type="text/javascript" src="${ctx}/assets/laydate/laydate.js"></script>
<script type="text/javascript" src="${ctx}/assets/layer/layer.js"></script>
<script type="text/javascript" src="${ctx}/js/touchTouchNew.jquery.js"></script>
<script type="text/javascript" src="${ctx}/assets/laydate/laydate.js"></script>
<link href="${ctx}/css/style.css" rel="stylesheet">
<link href="${ctx}/css/font-awesome.min.css" rel="stylesheet">
<link href="${ctx}/css/touchTouchNew.css" rel="stylesheet">
<link rel="stylesheet" href="${ctx}/css/sapar.css" />
<title>文库</title>

<style type="text/css">
.xuanzhong{
color: red;
}
/*body{background:url(images/65.jpg) no-repeat fixed center center;}*/
.clear{clear:both;}
.main-page{margin:10px 10px 10px 10;width:1320px;height:500px;}
.main-page .left, .main-page .right{float:left;}
.main-page .nav-back{width:60px;height:300px;background:#000;opacity:.3;filter:alpha(opacity=30);}
.main-page .nav{position:relative;margin-top:-300px;width:60px;text-align:center;font-size:14px;font-family:"微软雅黑";color:#fff;}
.main-page .nav div{height:32px;line-height:28px;}
.main-page .nav div.on{background:#0094ea;}
.main-page .right{width:1200px;height:450px;margin-left:10px;}
.main-page .content-back{width:620px;height:300px;opacity:.3;}
.main-page .content{position:relative;width:1200px;height:280px;margin-top:-300px;overflow:hidden;}
.main-page .content div{width:1200px;height:280px;margin-bottom:10px;background:#fff;}

.content div:nth-of-type(1){height:280px;overflow-y:auto;}

.top ul{display:flex;height:30px;}

.top ul li{list-style:none;margin-left:100px;line-height:28px;}
.top ul li.icon1{background: url(../imgs/icon05.1.png) no-repeat left center;background-size: 35%;padding-left: 24px;cursor: pointer;}
.top ul li.icon1:hover{background: url(../imgs/sc.png) no-repeat left center;background-size: 35%;padding-left: 24px;color: #fff;cursor: pointer;}
.top ul li.icon2{background: url(../imgs/icon06.1.png) no-repeat left center;background-size: 40%;padding-left: 24px;cursor: pointer;}
.top ul li.icon2:hover{background: url(../imgs/xz.png) no-repeat left center;background-size: 40%;padding-left: 24px;color: #0000FF;cursor: pointer;}
.top ul li.icon3{background: url(../imgs/icon04.1.png) no-repeat left center;background-size: 40%;padding-left: 24px;cursor: pointer;}
.top ul li.icon3:hover{background: url(../imgs/sc2.png) no-repeat left center;background-size: 40%;padding-left: 24px;color: #0000FF;cursor: pointer;}
.top ul li.icon4{background: url(../imgs/xg.png) no-repeat left center;background-size: 40%;padding-left: 24px;cursor: pointer;}
.top ul li.icon4:hover{background: url(../imgs/xg1.png) no-repeat left center;background-size: 40%;padding-left: 24px;color: #0000FF;cursor: pointer;}
#first{
height:480px;
padding-top: 5px;
display:flex;
flex-wrap:wrap;
} 
#three{
height:480px;
} 
#two{
height:484px;
} 
#ff{
height:480px;
}
#first>div{display:flex;flex-direction:column;width:16%;height:200px;overflow-x:auto;}
#first>div img{display:block;left:0;right:0;margin:auto}
#first>div>span:nth-of-type(1):{display:flex;}
.text-c{display:block;text-align:center;font-size:12px;}
td{
 text-align:center;
}
tr:nth-child(2n){
  background:rgb(239,246,250);
}
th{font-weight:normal;}
.top li input{height:20px;border:1px solid #ccc;border-top-left-radius:10px;border-bottom-left-radius:10px;margin-top:4px;}
.top li .clicka{display:inline-block;width:50px;height:22px;background:#59BC5E;color:#fff;text-decoration:none;line-height:20px;text-align:center;}
table{border:1px solid #c1d3de;margin-top:20px;}
table tr,table td{border:1px solid #c1d3de;line-height: 30px;}
</style>
</head>
<body>
<div class="main-page">
    <div class="subfiled clearfix">
				<h2>文库</h2>
			</div>
    <div class="top">
        <ul style="background:#4296dc">
			<li class="icon1"><a href="javascript:;" style="color: black; text-decoration: none;">上传</a></li>
			<li class="icon2"><a href="javascript:;" style="color: black; text-decoration: none;">下载</a></li>
			<li class="icon3"><a href="javascript:;" onclick="deletebatch()" style="color: black; text-decoration: none;">删除</a></li>
			<li class="icon4"><a href="javascript:;" onclick="xiugai()" style="color: black; text-decoration: none;">修改</a></li>
			<li><div><input id="txt" type="text" name="txt" value="${tj }"><a href="javascript:;" onclick="sosuo()" class="clicka">搜索</a></div></li>
		</ul>
    </div>
	<div class="left">
		<div class="nav-back"></div>
		<div class="nav">
			<div id="tu" class="on" onclick="tu()">图片</div>
			<div id="wen" onclick="wen()">文档</div>
			<div id="shi" onclick="shi()">视频</div>
			
		</div>
	</div>
	<div class="right">
		<div class="content-back"></div>
		<div class="content" id="ff">
            <div id="first" class="overfirst">
			    <c:if test="${file != null }">
			        <c:forEach items="${file }" var="tp">
                         <div class="tupian">
                            <!-- <span class="tupian"> -->
                               <%-- <a href="${ctx }${tp.shiftImg }">
                                 <img src="${ctx }${tp.shiftImg }" width="151px;" height="150px;">
                               </a> --%>
                               <input type="hidden" name="wj" value="${tp.fileId }" class="wj">
                                   <img src="../imgs/wjj.png" width="140px;" height="140px;">
						  <span class="text-c"><input type="checkbox" value="${tp.fileId }" name="key" >${tp.fileName }</span>
                         </div>	
					</c:forEach>
			    </c:if>
			    <div id="xinjian">
                    <img src="../imgs/xinjian.png" width="140px;" height="140px;">
                </div>
            </div>
			<div id="two">
			   <table style="width:100%;border-collapse:collapse" cellpadding="0" cellspacing="0">
                    <tr>
                    <td><input type="checkbox" name="checkall1" id="checkall1"></td>
                    <td>文件名</td>
                    <td>上传人</td>
                    <td>上传时间</td>
                    <td>操作</td>
                    </tr>
                    <c:if test="${wenjian != null }">
                    <c:forEach items="${wenjian }" var="wj">
                    <c:if test="${wj.shiftSort == 2 }">
                        <tr class="showwj" data="${wj.shiftId}">
                            <td><input type="checkbox" name="key1" id="" value="${wj.shiftId }" lujing="${ctx }${wj.shiftImg }"></td>
                            <td>${wj.shiftTitle }</td>
                            <td>${wj.employeeName }</td>
                            <td><fmt:formatDate value="${wj.shiftDate}" type="date" pattern="yyyy-MM-dd HH:mm:ss" /></td>
                            <td><img src="../imgs/dk.png" width="20px;" height="20px;" class="dakai"/></td>
                        </tr>
                    </c:if>
                    </c:forEach>
                    </c:if>
                </table>
            </div>
			<div id="three">
			    <table style="width:100%;border-collapse:collapse" cellpadding="0" cellspacing="0">
                    <tr>
                    <td><input type="checkbox" name="checkall" id="checkall2"></td>
                    <td>文件名</td>
                    <td>上传人</td>
                    <td>上传时间</td>
                    <td>操作</td>
                    </tr>
                    <c:if test="${shipin != null }">
                    <c:forEach items="${shipin }" var="sp">
                    <c:if test="${sp.shiftSort == 3 }">
                        <tr class="showsp" data="${sp.shiftId}">
                            <td><input type="checkbox" name="key2" id="" value="${sp.shiftId }" lujing="${ctx }${sp.shiftImg }"></td>
                            <td>${sp.shiftTitle }</td>
                            <td>${sp.employeeName }</td>
                            <td><fmt:formatDate value="${sp.shiftDate}" type="date" pattern="yyyy-MM-dd HH:mm:ss" /></td>
                            <td><img src="../imgs/bf.png" width="20px;" height="20px;" class="bofang"/></td>
                        </tr>
                    </c:if>
                    </c:forEach>
                    </c:if>
                </table>
			</div>
		</div>
	</div>
	<div class="clear"></div>
</div>
<script type="text/javascript">
$(function(){
//	var wj//文件夹编号(主键)
	$(".tupian img").click(function(){
		var wj=$(this).parent().find("input[name='wj']").val();
		window.location.href="${ctx }/shift/wenj.do?id="+wj;
	});
	$(".dakai").click(function(){
		$(this).parent().parent().addClass("xuanzhong").siblings().removeClass("xuanzhong");
		var shiftId = $(this).parent().parent().attr("data");
		//找儿子的典例
		var name = $(this).parent().parent().find("td:eq(1)").text();
		$.ajax({
			type:"post",
			url:"${ctx}/shift/wenjianSelect.do?id="+shiftId,
			error:function(){
				layer.alert("网络故障，稍后再试");
			},
			success:function(data){
				if(data.status=="true"){
	 	           	//window.location.reload();
	           	}
			}
		});
	});
	
	$(".bofang").click(function(){
		$(this).parent().parent().addClass("xuanzhong").siblings().removeClass("xuanzhong");
		var shiftId = $(this).parent().parent().attr("data");
		//找儿子的典例
		var name = $(this).parent().parent().find("td:eq(1)").text();
		layer.open({
			  type: 2,
			  title: name,
			  maxmin: true,
			  shadeClose: true, //点击遮罩关闭层
			  area : ['800px' , '520px'],
			  content: '${ctx}/shift/shipinSelect.do?id='+shiftId+'&name='+name
		});
	});
	
	$("#xinjian").click(function(){
		window.location.href="${ctx}/file/xinjian.do";
	});

    $(".icon1").click(function(){
        var leixing = i;
        window.location.href="${ctx}/shift/shiftEdit.do?lx="+leixing;
    });
    $(".icon2").click(function(){
        var btn = true;
//	var chks = getSelRecord();
        var chks1 = getSelRecord1();
        var chks2 = getSelRecord2();
        if(chks1.length>1){
            layer.msg("请选择要下载的文件，并且只能选择一个");
            btn=false;
        }
        if(chks1.length==1){
            if(chks2.length>=1){
                layer.msg("请选择要下载的文件，并且只能选择一个");
                btn=false;
            }
            if(chks2.length<1){
                btn=true;
            }
        }
        if(chks1.length<1){
            if(chks2.length!=1){
                layer.msg("请选择要下载的文件，并且只能选择一个");
                btn=false;
            }
            if(chks2.length==1){
                btn=true;
            }
        }
        var linklj = "http://192.168.1.105:8080";
        var dp;
        var fp;
        $("input[type='checkbox']").each(function(){
            if(this.checked){
                fp = $(this).attr("lujing");
                dp =linklj+fp;
            }
        });
        if(btn){
            window.location.href="${ctx}/shift/xiazai.do?fileUrl="+dp+"&downPath="+fp;
        }
    });
    $(".icon3").click(function(){
        var btn = true;
        var chks = getSelRecord();
        var chks1 = getSelRecord1();
        var chks2 = getSelRecord2();
        if(chks.length==0&&chks1==0&&chks2==0){
            layer.msg("请选择要刪除的文件");
            btn=false;
        }
        if(btn){
            $.ajax({
                type:"post",
                url:"${ctx}/shift/deletebatch.do?chk="+chks.join()+"&chk1="+chks1.join()+"&chk2="+chks2.join(),
                error:function(){
                    layer.alert("网络故障，稍后再试");
                },
                success:function(data){
                    if(data.status=="true"){
                        console.log(data);
                        layer.alert(data.msg,function(){
                            window.location.reload();
                            $("input[type='checkbox']").each(function(){
                                $(this).prop('checked',false);
                            });
                        });
                    }else{
                        layer.msg(data.msg);
                    }
                }
            });
        }
    });
    $(".icon4").click(function(){
        var btn = true;
        var leixing = i;
        var chks = getSelRecord();
        var chks1 = getSelRecord1();
        var chks2 = getSelRecord2();
        if(chks.length<1){
            if(chks1.length<1){
                if(chks2.length<1){
                    layer.msg("只能勾选一个！");
                    btn = false;
                }
                if(chks.length==1){
                    btn=true;
                }
                if(chks2.length>1){
                    layer.msg("只能勾选一个！")
                    btn = false;
                }
            }
            if(chks1.length==1){
                if(chks2.length<1){
                    btn = true;
                }
                if(chks2.length>=1){
                    layer.msg("只能勾选一个！");
                    btn = false;
                }
            }
            if(chks1.length>1){
                layer.msg("只能勾选一个！");
                btn = false;
            }
        }
        if(chks.length==1){
            if(chks1.length<1){
                if(chks2.length<1){
                    btn=true;
                }
                if(chks2.length>=1){
                    layer.msg("只能勾选一个！");
                    btn = false;
                }
            }
            if(chks1.length>=1){
                layer.msg("只能勾选一个！");
                btn = false;
            }
        }
        if(chks.length>1){
            layer.msg("只能勾选一个！");
            btn = false;
        }
        if(btn){
            var fileId;
            if(chks.length!=0){
                fileId = chks[0];
            }
            if(chks1.length!=0){
                fileId = chks1[0];
            }
            if(chks2.length!=0){
                fileId = chks2[0];
            }
            window.location.href="${ctx}/shift/shiftEdit.do?id="+fileId+"&lx="+leixing;
        }
    });
})

$(document).ready(function(e) {
	$('.content a').touchTouchNew();
	});
	$(".main-page .nav div").mouseenter(function () {
		var $this = $(this);
		var index = $this.index();
	}).mouseleave(function () {
		var $this = $(this);
		var index = $this.index();
	}).click(function () {
		var $this = $(this);
		var index = $this.index();
		var l = -(index * 493);
		$(".main-page .nav div").removeClass("on");
		$(".main-page .nav div").eq(index).addClass("on");
		$(".main-page .content div:eq(0)").stop().animate({ "margin-top": l }, 500);
	$("#checkall1").click(function(){
		if(this.checked){
			$("input[name='key1']").prop('checked',true);
		}else{
			$("input[name='key1']").prop('checked',false);
		}
    });
	$("#checkall2").click(function(){
		if(this.checked){
			$("input[name='key2']").prop('checked',true);
		}else{
			$("input[name='key2']").prop('checked',false);
		}
    });
	
});	

var i = 1;
function tu(){
	i = 1;
}
function wen(){
	i = 2;
}
function shi(){
	i = 3;
}

function getSelRecord(){
	var chk_value =[];
    $('input[name="key"]:checked').each(function(){
		chk_value.push($(this).val()); 
	});
	return chk_value;
}
function getSelRecord1(){
	var chk_value =[];
    $('input[name="key1"]:checked').each(function(){
		chk_value.push($(this).val()); 
	});
	return chk_value;
}
function getSelRecord2(){
	var chk_value =[];
    $('input[name="key2"]:checked').each(function(){
		chk_value.push($(this).val()); 
	});
	return chk_value;
}
function sosuo(){
	var ss = $("#txt").val();
	window.location.href="${ctx}/shift/wenkuList.do?tj="+ss;
}
function isNullOrEmpty(strVal){
	strVal = strVal.replace(/(^\s*)|(\s*$)/g,"");
	if(strVal == '' || strVal == null || strVal == undefined){
		return true;
	}else{
		return false;
	}
}
</script>

</body>
</html>